//
//  MainViewController.m
//  EasyTalk
//
//  Created by Easy.Lin on 15/11/6.
//  Copyright © 2015年 Gdut_Lizzy. All rights reserved.
//

#import "MainViewController.h"

#import "NewsViewController.h"
#import "StoreViewController.h"
#import "TrainingViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUpTabViews];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)setUpTabViews
{
    
    NewsViewModel * newsViewModel = [[NewsViewModel alloc] init];
    NewsViewController * newsViewController = [[NewsViewController alloc] initWithViewModel:newsViewModel];
    newsViewController.title = @"资讯交流";
    newsViewController.hidesBottomBarWhenPushed = NO;
    UINavigationController * nav_news = [[UINavigationController alloc] initWithRootViewController:newsViewController];
    nav_news.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"资讯交流"
                                                             image:
                                [self imageNamed:@"ic_homepage_s"]
                                                     selectedImage:
                                [self imageNamed:@"ic_homepage_g"]];
    
    TrainingViewModel * trainingViewModel = [[TrainingViewModel alloc] init];
    TrainingViewController * trainingViewController = [[TrainingViewController alloc] initWithViewModel:trainingViewModel];
    trainingViewController.title = @"锻炼计划";
    trainingViewController.hidesBottomBarWhenPushed = NO;
    UINavigationController * nav_Training = [[UINavigationController alloc] initWithRootViewController:trainingViewController];
    nav_Training.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"锻炼计划"
                                                            image:
                               [self imageNamed:@"ic_paihangban_s"]
                                                    selectedImage:
                               [self imageNamed:@"ic_paihangban_g"]];
    
    StoreViewModel * storeViewModel = [[StoreViewModel alloc] init];
    StoreViewController * storeViewController = [[StoreViewController alloc] initWithViewModel:storeViewModel];
    storeViewController.title = @"商城";
    storeViewController.hidesBottomBarWhenPushed = NO;
    UINavigationController * nav_Store = [[UINavigationController alloc] initWithRootViewController:storeViewController];
    nav_Store.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"商城"
                                                      image:
                         [self imageNamed:@"ic_guanzhu_s"]
                                              selectedImage:
                         [self imageNamed:@"ic_guanzhu_g"]];
    self.viewControllers = @[nav_news,nav_Training,nav_Store];
    self.selectedIndex = 1;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

- (UIImage *)imageNamed:(NSString *)name {
    return [[UIImage imageNamed:name] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}

#pragma mark - LifeCycle
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
